cmake_minimum_required(VERSION 3.0)
project(GhostBuddy VERSION 1.0.0)

set(CMAKE_CXX_FLAGS "-static -static-libgcc -static-libstdc++ -Wall -fpermissive")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -Og")

add_definitions(-DPROJECT_NAME="${CMAKE_PROJECT_NAME}")
add_definitions(-DPROJECT_EXPORT=${CMAKE_PROJECT_NAME})
add_definitions(-DPROJECT_VERSION="${CMAKE_PROJECT_VERSION}")

set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
option(USE_OWN_MINHOOK "Whether to use own MinHook instead of relying on runtime lookup using RedBlocklandLoader" ON)

if (USE_OWN_MINHOOK)
	message("-- MinHook: using own MinHook")
	set(USE_RBL_MINHOOK_RUNTIME false)
	add_compile_definitions(USE_RBL_MINHOOK_RUNTIME=false)
else ()
	message("-- MinHook: compiling with RBL MinHook function lookup at runtime")
	set(USE_RBL_MINHOOK_RUNTIME true)
	add_compile_definitions(USE_RBL_MINHOOK_RUNTIME=true)
endif ()

set(CMAKE_INSTALL_PREFIX "./build/")

include_directories("include/")
if (NOT USE_RBL_MINHOOK_RUNTIME)
	include_directories("minhook_project/include/")
endif ()


add_library(${CMAKE_PROJECT_NAME} SHARED
	src/main.cpp
)

set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")

if (NOT USE_RBL_MINHOOK_RUNTIME)
	message("-- Adding MinHook files")
	add_subdirectory(minhook_project)
	add_dependencies(${CMAKE_PROJECT_NAME} minhook)
	set_target_properties(minhook PROPERTIES IMPORTED_LOCATION "./build/minhook_project/minhook.x32.a")
	
	target_link_libraries(${CMAKE_PROJECT_NAME}
		minhook
	)
endif ()


target_link_libraries(${CMAKE_PROJECT_NAME}
	psapi
)

set(EXECUTABLE_OUTPUT_PATH ${dir}release)
set(LIBRARY_OUTPUT_PATH ${dir}release)

